﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SSN.DotNet;

namespace SSN.DotNextExtensionsTests
{
    [TestClass]
    public class FormatTests
    {
        [TestMethod]
        public void Formatters()
        {
            Assert.IsTrue("9360905".FormatAsPhone() == "936-0905");
            Assert.IsTrue("8659360905".FormatAsPhone() == "(865) 936-0905");
            Assert.IsTrue("444551111".FormatAsSocial() == "444-55-1111");
            Assert.IsTrue("445555555".FormatAsTaxID() == "44-5555555");
            Assert.IsTrue("0000".FormatAsPhone() == "   -0000");
        }

        [TestMethod]
        public void Strippers()
        {
            Assert.IsTrue("555-44-7777".StripNonNumbers() == "555447777");
            Assert.IsTrue("T|r&a|v&i|s".Strip("&|".ToCharArray()) == "Travis");
            Assert.IsTrue("Travis41Houk".StripNumbers() == "TravisHouk");
            Assert.IsTrue("    T   r\r\ra\n\nv\t\tis   ".StripWhiteSpace() == "Travis");
        }

        [TestMethod]
        public void NumberFormats()
        {
            double d = 3.141782903;
            Assert.IsTrue(d.ToStandardString(false, 2) == "3.14");
            d = 874251325.4;
            Assert.IsTrue(d.ToStandardString(true, 3) == "874,251,325.400");
            int i = 1000000;
            Assert.IsTrue(i.ToCommaString() == "1,000,000");
        }
    }
}
